Win32: Refactor, split off and fix resize logic and DPI changes handling #178
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR refactors and splits off the logic that handles re-sizing and discovering/updating the window's DPI.
Some of that logic is split off into a new, low-level
Win32Window
type, which only handles translating baseview types and assumptions intoWin32
calls, separately from managing events or the window handler.This is part of the effort to split up #174 into smaller pieces.
This PR actually changes the logic, mainly by also splitting the internal
window_info
into two separate components,current_size
(physical) andcurrent_scale_factor
, which are instead updated independently during their respective events.Incidentally, this PR also fixes a few bugs:
WM_DPICHANGE
event triggering a window resize but not triggering a resize event in the window handler. This supersedes the work done in Fix WM_DPICHANGED not triggering Resized event #140.WM_DPICHANGE
event to use the OS-provided window dimensions and position, instead of computing our own dimensions and leaving the position as-is. This avoids a DPI-change loop due to the window constantly switching between two monitors as it's being dragged across them using the mouse.This has all been tested on my Windows 10 machine and works as expected.